package com.sd.controller;

import com.sd.entity.ReturnBean;
import com.sd.service.StudentHospitalService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @author ：IvanZ
 * @version : 1.0
 * @date ：Created on 2021/1/11 15:46
 * @description ：主页控制器
 * @modified By：
 */
@Controller
public class IndexController   extends  BaseController{
    @Resource
    StudentHospitalService studentHospitalService;

    @RequestMapping("toCustomIndex")
    public String toCustomIndex() {
        return "index";
    }

    @RequestMapping("toCustomLogin")
    public String toCustomLogin() {
        return "website/customLogin";
    }

    @RequestMapping("getMyCount")
    @ResponseBody
    public ReturnBean getMyCount(){
        List<List<Object>> retureData= new ArrayList<>();
        List<Map<String, Object>> myCount = studentHospitalService.getMyCount();
        String[] head = {"product", "计划报名人数", "已经报名人数"};
        retureData.add(Arrays.asList(head));
        for (Map<String, Object> map : myCount) {
            List<Object> temp= new ArrayList<>();
            //活动名称
            temp.add( map.get("name"));
            //计划报名的人数
            temp.add( map.get("planCount"));
            //已经报名的人数
            temp.add( map.get("doneCount"));
            retureData.add(temp);
        }
        return   returnSuccess(retureData);

    }
}
